﻿
namespace SomethingSpacialClassLib.Web
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Data;
    using System.Linq;
    using System.ServiceModel.DomainServices.Server;
    using System.ServiceModel.DomainServices.EntityFramework;


    // Implements application logic using the SUGWTKEntities1 context.
    // TODO: Add your application logic to these methods or in additional methods.
    // TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
    // Also consider adding roles to restrict access as appropriate.
    // [RequiresAuthentication]
    public partial class SomethingSpacialService : LinqToEntitiesDomainService<SUGWTKEntities1>
    {

        // TODO: Consider
        // 1. Adding parameters to this method and constraining returned results, and/or
        // 2. Adding query methods taking different parameters.
        public IQueryable<Sponsor> GetSponsors()
        {
            return this.ObjectContext.Sponsors;
        }

        public void InsertSponsor(Sponsor sponsor)
        {
                if ((sponsor.EntityState != EntityState.Detached))
                {
                    this.ObjectContext.ObjectStateManager.ChangeObjectState(sponsor, EntityState.Added);
                }
                else
                {
                    this.ObjectContext.Sponsors.AddObject(sponsor);
                }
        }

        public void UpdateSponsor(Sponsor currentSponsor)
        {
                this.ObjectContext.Sponsors.AttachAsModified(currentSponsor, this.ChangeSet.GetOriginal(currentSponsor));
        }

        public void DeleteSponsor(Sponsor sponsor)
        {
            if ((sponsor.EntityState == EntityState.Detached))
            {
                this.ObjectContext.Attach(sponsor);
            }
            this.ObjectContext.Sponsors.DeleteObject(sponsor);
        }

    }
}


